import * as Api from '@/api/system/user'

const user = {
  state: {
  },
  mutations: {
  },
  actions: {
    GetUserPage({ commit }, param) {
      return new Promise((resolve, reject) => {
        Api.getUserPage(param)
          .then(res => {
            resolve(res.data)
          })
          .catch(err => {
            reject(err)
          })
      })
    },
    GetUserById({ commit }, id) {
      return new Promise((resolve, reject) => {
        Api.getUserById(id)
          .then(res => {
            resolve(res.data)
          })
          .catch(err => {
            reject(err)
          })
      })
    },
    SaveUser({ commit }, data) {
      return new Promise((resolve, reject) => {
        Api.saveUser(data)
          .then(res => {
            resolve(res.data)
          })
          .catch(err => {
            reject(err)
          })
      })
    },
    UpdateUserById({ commit }, { id, data }) {
      return new Promise((resolve, reject) => {
        Api.updateUserById(id, data)
          .then(res => {
            resolve(res.data)
          })
          .catch(err => {
            reject(err)
          })
      })
    },
    RemoveUserById({ commit }, id) {
      return new Promise((resolve, reject) => {
        Api.removeUserById(id)
          .then(res => {
            resolve(res.data)
          })
          .catch(err => {
            reject(err)
          })
      })
    }
  }
}

export default user
